var features = false;
var pictures = [];
var related = [];
var t;

$(document).ready(function() {

    $("ul.dropdown-menu").children("li").click(function() {
        $(this).parents("ul").children("li").removeClass("active");
        $(this).addClass("active");
        $(this).parent("ul").prev("button").html($(this).html() + "<span class=\"caret\">");
        $(this).parent("ul").parent("div").next("p").text("");
    });
    $("#formCreatePayment").submit(function(event) {
        event.preventDefault();
        var name = $("#inputRegisterName").val();
        var fullDescritpion = $("#textarea_opisPelny").val();
        var shortDesription = $("#textarea_opisKrotki").val();
        var active = $("#active").val();
        var shopname = $("#shopname").val();
        var url = "/" + shopname + "/ShopAdmin_Configuration/payments";
        $.post(url,
                {
                    name: name,
                    active: active,
                    fullDescritpion: fullDescritpion,
                    shortDesription: shortDesription

                }).done(function(evt) {
            window.location.href = "/" + shopname + "/ShopAdmin_Configuration/payments";
        });
    });
    $(".submitPayment").click(function() {
        var id = $(this).parent().parent().children("input[name=paymentID]").val();
        var name = $(this).parent().parent().children("td").children("input[name=PaymentName]").val();
        var description = $(this).parent().parent().children("td").children("textarea[name=PaymentDescription]").val();
        var active = $(this).parent().parent().children("td").children("select[name=PaymentActive]").val();
        var mail = $(this).parent().parent().children("td").children("textarea[name=PaymentMail]").val();
        var shopname = $("#shopname").val();
        var url = "/" + shopname + "/ShopAdmin_Configuration/payments";
        $.post(url,
                {
                    name: name,
                    active: parseInt(active),
                    fullDescritpion: description,
                    shortDesription: mail,
                    id: id

                }).done(function(evt) {
           window.location.href = "/" + shopname + "/ShopAdmin_Configuration/payments";
        });
    });
});